package com.caucho.hessian.callback;

import java.net.MalformedURLException;
import java.util.Map;

import com.caucho.hessian.service.HessianService;


public class HessianCallbackProxy implements HessianCallbackService{
	private HessianCallback callback;
	public HessianCallbackProxy(HessianCallback callback){
		this.callback=callback;
	}
	@Override
	public String callback(Map<String, String> map) throws MalformedURLException {
		if(callback.getMap()!=null && !callback.getMap().isEmpty()){
			if(map==null){
				map=callback.getMap();
			}else{
				map.putAll(callback.getMap());
			}
		}
		HessianCallbackService service=  HessianService.call(HessianCallbackService.class, callback.getCallbackUrl());
    	return service.callback(map);
	}

}
